package com.botu.springcloudaibabadiscovery;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import java.util.concurrent.TimeUnit;

@SpringBootApplication
@EnableDiscoveryClient
public class SpringCloudAibabaDiscoveryApplication {

    public static void main(String[] args) {
        ConfigurableApplicationContext applicationContext = SpringApplication.run(SpringCloudAibabaDiscoveryApplication.class,args);
        /*while(true){
            String userName = applicationContext.getEnvironment().getProperty("user.name");
            System.err.println("userName:"+userName);
            try {
                TimeUnit.SECONDS.sleep(5);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }*/
    }

    @RestController
    public class EchoController{
        @GetMapping(value = "/echo/{string}")
        public String echo(@PathVariable String string){
            return "Hello Nacos Discovery2" + string;
        }
    }

}
